package com.ruibang.glass.produce.service.impl;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.ruibang.glass.produce.entity.DefectSampleItem;
import com.ruibang.glass.produce.mapper.DefectSampleItemMapper;
import com.ruibang.glass.produce.service.DefectSampleItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 溶解缺陷取样项目 服务实现类
 * </p>
 *
 * @author songJinKang
 * @since 2024-04-28
 */
@Service
public class DefectSampleItemServiceImpl extends ServiceImpl<DefectSampleItemMapper, DefectSampleItem> implements DefectSampleItemService {


    @Override
    public void removeBySampleId(String id) {
        if (StringUtils.isNotBlank(id)) {
            lambdaUpdate().eq(DefectSampleItem::getSampleId, id).remove();
        }
    }


    @Override
    public List<DefectSampleItem> getBySampleIds(List<String> sampleIds) {
        if (CollectionUtils.isNotEmpty(sampleIds)) {
            return lambdaQuery().in(DefectSampleItem::getSampleId, sampleIds).list();
        }
        return Collections.emptyList();
    }

    @Override
    public void deleteBySampleId(String sampleId) {
        lambdaUpdate().eq(DefectSampleItem::getSampleId, sampleId).remove();
    }
}
